﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using VOL.Core.EFDbContext;
using VOL.Core.Utilities;
using VOL.Entity.AttributeManager;
using VOL.Entity.DomainModels.WorkforceManage;
using VOL.SmartMecial.Dtos;
using VOL.SmartMecial.IServices.WorkforceManage;

namespace VOL.WebApi.Controllers.SmartMecial
{
    /// <summary>
    /// 工作力量管理控制器
    /// 负责处理护士排班和工作安排相关的API请求
    /// </summary>
    [Route("api/WorkforceController")]
    [PermissionTable(Name = "WorkforceController")]
    public class WorkforceController : ControllerBase
    {
        private readonly IWorkforceService _svcWorkforce;

        /// <summary>
        /// 构造函数，通过依赖注入获取工作力量服务实例
        /// </summary>
        /// <param name="svcWorkforce">工作力量服务</param>
        public WorkforceController(IWorkforceService svcWorkforce)
        {
            this._svcWorkforce = svcWorkforce;
        }

        /// <summary>
        /// 获取指定年月班次的工作力量安排
        /// </summary>
        /// <param name="year">年份</param>
        /// <param name="month">月份</param>
        /// <param name="stage">班次</param>
        /// <returns>工作力量安排数据</returns>
        [HttpGet("GetWorkforce")]
        public Task<WebResponseContent> GetWfWorkforce(int year,int month,int stage)
        {
            return _svcWorkforce.GetWorkforces( year ,month,  stage);
        }

        /// <summary>
        /// 批量添加工作力量安排
        /// </summary>
        /// <param name="lstWorkforce">工作力量模型列表</param>
        /// <returns>操作结果</returns>
        [HttpPost("AddWorkforces")]
        public async Task<WebResponseContent> AddWfWorkforces([FromBody] List<WorkforceModel> lstWorkforce)
        {
            return await _svcWorkforce.AddWorkforeces(lstWorkforce);
        }

        /// <summary>
        /// 获取护士列表
        /// </summary>
        /// <returns>护士列表数据</returns>
        [HttpGet("GetNurseList")]
        public Task<WebResponseContent> GetNurseList()
        {
            return _svcWorkforce.GetNurseList();
        }

        /// <summary>
        /// 获取工作力量详情
        /// </summary>
        /// <param name="dtoDetail">工作力量详情查询参数</param>
        /// <returns>工作力量详情数据</returns>
        [HttpPost("GetWorkforcesDetail")]
        public Task<WebResponseContent> GetWfWorkforcesDetail([FromBody] GetWorkforceDetailDto dtoDetail)
        {
            return _svcWorkforce.GetWorkforcesDetail(dtoDetail);
        }

        /// <summary>
        /// 批量更新工作力量安排
        /// </summary>
        /// <param name="lstWorkforce">工作力量模型列表</param>
        /// <returns>操作结果</returns>
        [HttpPost("UpdWorkforces")]
        public async Task<WebResponseContent> UpdWfWorkforces([FromBody] List<WorkforceModel> lstWorkforce)
        {
            return await _svcWorkforce.UpdWorkforeces(lstWorkforce);
        }
    }
  
}